<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title></title>
</head>
<script type="text/javascript" src="js/jquery-3.2.1.min.js"></script>
<script type="text/javascript" src="js/public.js"></script>
<script type="text/javascript" src="js/jquery.cookie.js"></script>
<script type="text/javascript">
    $(function(){
        $("#userName").html(GetCookie("hello_user_name"));

        $("#test").click(function(){
            var user = {"id":"1"};
            //请求服务器
            $.ajax({
                url:requestUrl+"user/getUserInfoById",
                contentType:"application/json;charset=utf-8",
                type:"POST",
                dataType:"json",
                data:JSON.stringify(user),
                headers:{
                    "Authentication":$.cookie("hello_token")
                },
                success:function(result){
                    alert(result.msg);
                    if(result.code == "102"){
                        window.location.href = "login.html";
                    }
                },
                error:function(){
                    alert("请求异常!");
                }
            });
        });
    });
</script>
<body>
    <center>
        <h1 id="userName"></h1>
        <button type="button"  id="test">请求服务器</button>
    </center>
</body>
</html>